package com.example.KeHuDuan;

import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

public class MainApp extends Application {
    private static final String TAG = MainApp.class.getSimpleName();
    private Intent intent;
    @Override
    public void onCreate() {
        super.onCreate();
        intent = new Intent(MainApp.this, MediaService.class);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            startForegroundService(intent);

        } else {
            startService(intent);
        }
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        Log.d(TAG, "onTerminate");
        stopService(intent);
    }
}
